package solitaire.deck;

import java.awt.geom.Point2D;
import java.util.ArrayList;

public class PileCollection extends ArrayList<Pile> {

	// Returns a pile object if the given point is where the pile is positioned (use pile contains method)
	public Pile findPile(Point2D point)
	{
		for (Pile p : this)
		{
			if (p.contains(point))
			{
				return p;
			}			
		}
		return null;
	}
	
	// Returns a card object if the given point is where the card is positioned (use card contains method)
	public Card findCard(Point2D point)
	{
		Card result = null;
		for (Pile p : this)
		{
			result = p.findCard(point);
			if(result != null)
				return result;
		}
		return result;
		
	}
	
	//Returns collection of cards object if given point is where the card is positioned.
	public CardCollection findCardCollection(Point2D point)
	{
		CardCollection result = new CardCollection();
		for (Pile p : this)
		{
			result = p.findCardCollection(point);
			if(result != null)
				return result;
		}
		return result;
	}
}
